from selenium import webdriver
from unittest import TestCase
from ddt import ddt,data,unpack
from 测试数据.Testnum1 import Testnumber
from 页面对象.LoginPage import LoginPage

@ddt
class TestLogin(TestCase):
    @data(*Testnumber().excel1)
    @unpack
    def testLoginSuccess1(self,username,password,expect):
        driver = webdriver.Chrome()
        driver.maximize_window()
        driver.get("http://192.168.139.128:90/")
        driver.implicitly_wait(10)
        login = LoginPage(driver)

        login.login(username,password)

        result = driver.title
        # if result!=expect:
        #     driver.save_screenshot(username+password+".png")
        driver.quit()
        self.assertEqual(expect,result)

    @data(*Testnumber().excel1_2)
    @unpack
    def testLoginNoUser(self, username, password, expect):
        driver = webdriver.Chrome()
        driver.maximize_window()
        driver.get("http://192.168.139.128:90/")
        driver.implicitly_wait(10)
        login = LoginPage(driver)

        result = login.loginNouser(username, password)


        # if result!=expect:
        #     driver.save_screenshot(username+password+".png")
        driver.quit()
        self.assertEqual(expect, result)

    @data(*Testnumber().excel1_3)
    @unpack
    def testLoginNoPass(self, username, password, expect):
        driver = webdriver.Chrome()
        driver.maximize_window()
        driver.get("http://192.168.139.128:90/")
        driver.implicitly_wait(10)
        login = LoginPage(driver)

        result = login.loginNoPass(username, password)

        # if result!=expect:
        #     driver.save_screenshot(username+password+".png")
        driver.quit()
        self.assertEqual(expect, result)